package com.tian.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

/**
 * {@code @description:} Swagger配置
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-07-28 19:47
 * {@code @version:} 1.0
 */

@Configuration   //加入到容器里面
@EnableSwagger2 //开启Swagger
public class SwaggerConfig {

    @Bean
    public Docket docket() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.tian.controller"))
                .build();
    }
    private ApiInfo apiInfo(){
        Contact contact = new Contact("充电桩项目：营销中心", "https://www.woaijava.cc/", "251965157@qq.com");
        return new ApiInfo(
                "充电桩项目：营销中心API文档",
                "营销中心API文档",
                "v1.0",
                "https://www.woaijava.cc/",
                contact,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }

}